package com.usian.service.impl;

import com.usian.controller.UserController;
import com.usian.mapper.UserMapper;
import com.usian.pojo.User;
import com.usian.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    private static  final Logger LOGGER = LoggerFactory.getLogger(UserServiceImpl.class);

    @Autowired
    private UserMapper userMapper;

    @Override
    public List<User> findAll() {
       // return userMapper.selectAll();
        LOGGER.info("11111111111");
        return userMapper.selectList(null);
    }


    @Override
    public User findById(Integer id){
        //return userMapper.selectByPrimaryKey(id);
        return userMapper.selectById(id);
    }

    @Override
    public List<User> findByUserName(String userName, String password) {
        return userMapper.findByUserName(userName,password);
    }

    @Override
    public void insertUser(User user) {
        //userMapper.insertSelective(user);
        userMapper.insert(user);
    }

    @Override
    public void delUser(Integer userId) {
        //userMapper.deleteByPrimaryKey(userId);
        userMapper.deleteById(userId);
    }

    @Override
    public void updateUser(User user) {
        //userMapper.updateByPrimaryKeySelective(user);
        userMapper.updateById(user);
    }
}
